/*
 * @Description:
 * @Version: 2.0
 * @Author: Yaowen Liu
 * @Date: 2021-10-14 13:34:56
 * @LastEditors: Yaowen Liu
 * @LastEditTime: 2023-09-21 09:23:25
 */
import request from '@/utils/request'
/**
 * 获取随机ID
 * @param {*} length
 * @returns
 */
export function randomID(length = 6) {
  return Number(Math.random().toString().substr(3, length) + Date.now()).toString(36)
}

// 获取用户笔记列表
export const getList = ({ page = 1 }) => {
  return request.get('/note/UserNote/noteList', {
    page,
  })
}

/**
 * 获取笔记详情
 * note_id 笔记ID
 * user_id 当前登陆人的会员ID
 *
 * */
export const getNoteDetail = ({ note_id = '', user_id = '' }) => {
  return request.post('/note/UserNote/noteInfo', {
    note_id,
    user_id,
  })
}

/**
 * 发布评论
 * uniacid
 * user_id 提交评论的会员ID
 * note_id 笔记ID
 * comment_content 评论内容
 * comment_cover_id 笔记下对其他评论的评论ID，如果上一级为0；
 * comment_user_id  笔记下评论内容会员的id
 * */
export const commentNote = (params: any) => {
  return request.post('/note/UserNote/commentNote', params)
}

/**
 * 点赞/收藏
 * uniacid
 * user_id 当前登陆人的会员ID
 * note_id 笔记ID
 * type 点赞类型，1点赞，2收藏
 * selected_state 点亮状态，1点亮，2取消
 * */
export const collectNote = (params: any) => {
  return request.post('/note/UserNote/noteCollect', params)
}

/**
 * 删除笔记
 * note_id
 * */
export const deleteNote = (params: any) => {
  return request.post('/note/UserNote/noteDel', params)
}
